package com.sc.sc250601.cook.controller;

import com.sc.sc250601.cook.pojo.Result;
import com.sc.sc250601.cook.pojo.UserFollow;
import com.sc.sc250601.cook.service.UserFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/userFollow")
public class UserFollowController {
    @Autowired
    UserFollowService userFollowService;
    @RequestMapping("/getAllFollowedId")
    public Result getAllFollowedId(Long id){
        List<Long> followedIds=userFollowService.selectAllFollowedId(id);

        if(followedIds!=null){
            return new Result(1,"查询所有被关注者成功",followedIds);
        }
        return new Result(0,"查询所有被关注者失败");
    }

    @RequestMapping("/add")
    public Result add(@RequestBody UserFollow uf){
   int n= userFollowService.add(uf);
   if(n>0){
       return new Result(1,"关注成功");
   }
   return new Result(0,"关注失败");
    }
    @RequestMapping("/del")
    public Result del(@RequestBody UserFollow uf){
        int n= userFollowService.del(uf);
        if(n>0){
            return new Result(1,"取消关注成功");
        }
        return new Result(0,"取消关注失败");
    }
}
